import { BrowserRouter, Route, Routes,Navigate } from "react-router-dom";
import { lazy,Suspense} from "react";
let arr = [
  {
    path: "/",
    to: "/home",
  },
  {
    path: "/home",
    element: lazy(() => import("../views/home/index")),
  },
  {
    path: "/Config",
    element: lazy(() => import("../views/Config/index")),
  },
  {
    path: "/Jianguan",
    element: lazy(() => import("../views/jianguan/index")),
  },
  {
    path: "/Taishi",
    element: lazy(() => import("../views/taishi/index")),
  },
];
const Router = () => {
  return (
    <Suspense fallback={<div>loading...</div>}>
    <BrowserRouter>
      <Routes>{
        arr.map((item,index)=>{
            return (
                <Route
                key={index}
                path={item.path}
                element={item.element?<item.element></item.element>:<Navigate to={item.to}></Navigate>}
                ></Route>
            )
        })
        }</Routes>
    </BrowserRouter>
    </Suspense>
  );
};
export default Router;
